//
// Description: 1893. 检查是否区域内所有整数都被覆盖
// Created by Loading on 2021/7/23.
//

#include <bits/stdc++.h>

using namespace std;

bool isCovered(vector<vector<int>> &ranges, int left, int right) {
    /* 差分数组 */
    vector<int> diff(60);
    for (auto &v : ranges) {
        diff[v[0]]++;
        diff[v[1] + 1]--;
    }
    // 差分数组前缀和
    /* 可以表示当前元素的覆盖次数 */
    vector<int> diffSum(60);
    for (int i = 1; i < 60; ++i) {
        diffSum[i] = diffSum[i - 1] + diff[i];
    }
    for (int i = left; i <= right; ++i) {
        if (diffSum[i] <= 0) {
            return false;
        }
    }
    return true;
}

int main() {
    vector<vector<int>> ranges = {{1,  10},
                                  {10, 20}};
    int left = 21;
    int right = 21;

    cout << isCovered(ranges, left, right) << endl;
}